package com.xhd.servlet;

import javax.servlet.http.HttpServlet;
import javax.servlet.ServletException;

import com.xhd.auth.AccessControl;
import com.xhd.server.EventObject;
import com.xhd.server.ServerConfig;

public class InitServlet extends HttpServlet {
	private static final long jm51 = 1L;

	public void init() throws ServletException {
		ServerConfig.SystemName = getInitParameter("systemname");
		String str1 = getInitParameter("systempath");
		String str2 = getInitParameter("servereventclass");
		if ((str1 != null) && (str1.length() > 0))
			ServerConfig.setSystemPath(str1);
		if ((str2 != null) && (str2.length() > 0))
			try {
				EventObject localEventObject = (EventObject) Class
						.forName(str2).newInstance();
				ServerConfig.Event = localEventObject;
			} catch (Throwable localThrowable) {
				localThrowable.printStackTrace();
			}
		AccessControl.getInstance();
	}

	public void destroy() {
		if (ServerConfig.Event == null)
			return;
		ServerConfig.Event.onEvent(EventObject.TIME_AFTER
				| EventObject.EVENT_STOP_SYS);
		super.destroy();
	}
}
